#include "Texture.h"


CTexture::CTexture(void)
{
}
CTexture::CTexture(LPDIRECT3DDEVICE9 _pd3device)
{
	m_pd3Device = _pd3device;
}

LPDIRECT3DTEXTURE9 CTexture::getTexture(string _filename)
{
	return getTexture(_filename, D3DCOLOR_XRGB(255, 255, 255));
}

LPDIRECT3DTEXTURE9 CTexture::getTexture(string _filename, D3DCOLOR _colorKey)
{
	HRESULT result;
	result = D3DXGetImageInfoFromFile(_filename.c_str(), &m_info);
	if (FAILED(result))
	{
		return NULL;
	}
	result = D3DXCreateTextureFromFileEx(m_pd3Device, _filename.c_str(), m_info.Width, m_info.Height, 1, D3DPOOL_DEFAULT, D3DFMT_UNKNOWN, D3DPOOL_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, _colorKey, &m_info, NULL, &m_texture);
	if (FAILED(result))
	{
		return NULL;
	}
	return m_texture;
}

D3DXIMAGE_INFO CTexture::getTextureInfo()
{
	return m_info;
}

CTexture::~CTexture(void)
{
}
